Skip to content

feat(bridge): inject recent conversation history when session resets#319

Merged
jinon86 merged 1 commit into
mainfrom
feat/bridge-history-injection-on-session-reset
Jul 7, 2026
Merged

feat(bridge): inject recent conversation history when session resets#319
jinon86 merged 1 commit into
mainfrom
feat/bridge-history-injection-on-session-reset

Conversation

@seoseo-ai

Copy link
Copy Markdown
Collaborator

Summary

  • 세션 만료/브릿지 재시작 후 새 Claude 세션이 시작될 때 이전 대화 맥락을 자동 주입
  • effective_sid == None + stale_session_id 존재 조건에서 get_recent_messages()로 최근 6교환 읽기
  • 읽은 내용을 [이전 대화 맥락 — 세션 전환으로 자동 주입됨] 블록으로 메시지 앞에 삽입
  • 히스토리 읽기 실패 시 silent fallback — 기존 동작 유지

Motivation

사용자가 "1/2/3 중 선택" 프롬프트에 "2"로 답했을 때, 세션이 끊긴 경우 대교가 맥락을 잃고 "'2'가 무엇인지 모르겠다"고 응답하는 문제 수정. JSONL 히스토리 파일(~/.claude/projects/)과 기존 get_recent_messages() 헬퍼를 활용.

Test plan

  • 세션 만료 후 단답 메시지 송신 → 이전 맥락 주입 확인 (bot.log History injection: 로그)
  • 히스토리 없는 첫 메시지 → 정상 동작 (send_text == text)
  • JSONL 파일 없는 경우 → warning 로그만, 에러 없음

🤖 Generated with Claude Code

@seoseo-ai seoseo-ai requested a review from jinon86 as a code owner July 7, 2026 01:39
When a Claude Code session expires or the bridge restarts, the next
user message previously arrived in a blank new session — losing all
context (e.g. user answering '2' to a numbered-option prompt got
"what does 2 mean?" back).

Fix: before calling process_message(), capture the stale session_id
and read the last 6 exchanges via get_recent_messages(). If the
effective_sid is None (new session) but a prior session exists, the
exchanges are prepended to the user message as a clearly-labelled
context block so Claude can interpret short replies in context.

Falls back silently on read errors so existing behaviour is unchanged
when no history is available.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@seoseo-ai seoseo-ai force-pushed the feat/bridge-history-injection-on-session-reset branch from a94204a to 6015104 Compare July 7, 2026 01:42

@jinon86 jinon86 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — history injection logic is clean and well-scoped. Silent fallback on read errors ensures no regression for existing flows. All CI green.

@jinon86 jinon86 merged commit a0059d8 into main Jul 7, 2026
7 checks passed
@jinon86 jinon86 deleted the feat/bridge-history-injection-on-session-reset branch July 7, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants